<script lang="ts" setup>
import { computed } from "vue";
import { NAvatar } from "naive-ui";
import { useUserStore } from "@/store";
import { isString } from "@/utils/is";
import defaultAvatar from "@/assets/ask_icon.png";
import answerIcon from "@/assets/answer_icon.png";
interface Props {
  image?: boolean;
}
defineProps<Props>();

const userStore = useUserStore();

const avatar = computed(() => userStore.userInfo.avatar);
</script>

<template>
  <template v-if="image">
    <NAvatar
      v-if="isString(avatar) && avatar.length > 0"
      :src="avatar"
      :fallback-src="defaultAvatar"
    />
    <NAvatar v-else round :src="defaultAvatar" />
  </template>

  <NAvatar v-else round :src="answerIcon" />
</template>
